<?php
header('Content-Type:text/html;charset=utf8');
$redis = new Redis();
$redis->connect('127.0.0.1',6379);


//=======================string=============
//$redis->set('string1','val1');
//$val = $redis->get('string1');
//$redis->set('string1',4);
//$redis->incr('string1',2);
//$val = $redis->get('string1');
//echo $val;


//==============================list===========
//$redis->lPush('list1','A');
//$redis->lPush('list1','B');
//$redis->lPush('list1','C');
//$val = $redis->rPop('list1');
//echo $val;

//========================set=========================
//$redis->sAdd('set1',"C");
//$redis->sAdd('set1',"B");
//$redis->sAdd('set1',"A");
////$redis->sAdd('set1',"C");
//////查询这个键的数据条数
////$count = $redis->sCard('set1');
////echo $count;
//
//$arr = $redis->sMembers('set1');
//print_r($arr);



//============================hash=======================
//$redis->hSet('driver1',"name","liuhao");
//$redis->hSet("driver1","age",25);
//$redis->hSet("driver1","gender","男");
//$val = $redis->hGet("driver1","name");
//var_dump($val);
//$vals = $redis->hMGet("driver1",["name","age"]);
//var_dump($vals);


//========================zsort===========================
$redis->zAdd('zset1',100,'xm');
$redis->zAdd('zset1',90,'xh');
$redis->zAdd('zset1',80,'xx');
$val = $redis->zRange("zset1",0,-1);//从低到高
var_dump($val);
$val = $redis->zRevRange("zset1",0,-1);//从高到低
var_dump($val);










